#include <lib/hash.h>

/**
 * @brief Hash a string using the djb2 algorithm
 * @ref http://www.cse.yorku.ca/~oz/hash.html
 */
u32 strhash32(const char* str) {
    if (!str)
        return 0;

    u32 hash = 5381;
    int c;

    while ((c = *str++))
        hash = ((hash << 5) + hash) + c;

    return hash;
}